<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>08_员工列表练习</title>
</head>
<body>
<input type="text" id="d1" placeholder="请输入员工姓名">
<input type="text" id="d2" placeholder="请输入员工工资">
<input type="text" id="d3" placeholder="请输入员工岗位">
<button onclick="addE()">添加员工</button>
<hr>
<table border="1px">
    <caption>员工表</caption>
    <tr>
        <th>姓名</th>
        <th>工资</th>
        <th>岗位</th>
    </tr>
    <script>

        let arr=[];
        function addE(){
            let name=document.getElementById('d1').value;
            let salary=document.getElementById('d2').value;
            let job=document.getElementById('d3').value;
            let tr=document.createElement('tr');
            let natd=document.createElement('td');
            let satd=document.createElement('td');
            let jotd=document.createElement('td');
            natd.innerHTML=name;
            satd.innerHTML=salary;
            jotd.innerHTML=job;
            tr.append(natd,satd,jotd)
            console.log(tr);
            let table=document.querySelector('table');
            table.append(tr);
            document.getElementById('d1').value='';
            document.getElementById('d2').value='';
            document.getElementById('d3').value='';

            arr.push({
                uname: name,
                usalary: salary,
                ujob: job
            })
            console.log(arr);





        }





    </script>
</table>
</body>
</html>